<?php
// Admin_Builder::configure(dirname(__FILE__)."/admin/config.yml");
class Admin_Builder
{
  static protected $config;
  
  static public function configure($config)
  {
    if (is_string($config) && is_file($config))
      self::$config = sfYaml::load($config);
    else
      self::$config = (array) $config;
    add_action('admin_menu', array('Admin_Builder', 'build'));
  }
  
  static public function build()
  {
    if (isset(self::$config['admin']))
    {
      foreach ((array) self::$config['admin'] as $pageconfig)
      {
        $classname = $pageconfig['type'];
        $page = new $classname();
        $page->register($pageconfig);
      }
    }
  }
}